`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: 
// Engineer: 
// 
// Create Date:    14:50:28 04/26/2014 
// Design Name: 
// Module Name:    audio_arrow 
// Project Name: 
// Target Devices: 
// Tool versions: 
// Description: 
//
// Dependencies: 
//
// Revision: 
// Revision 0.01 - File Created
// Additional Comments: 
//
//////////////////////////////////////////////////////////////////////////////////
module audio_arrow(melody, out, reset, M);

   output reg [3:0] out;
   
	input [5:0] melody;
	input reset;
	input [9:0]M;
	reg [3:0]seed;

   reg [23:0] count_melody;

   initial begin
   seed = 4'b0000;
	count_melody = 24'b000000000000000000000000;
   end
	
	always @(melody) 
	begin
		if (reset) 
		 begin
			out <= seed;
		 end
		
//NEW CLOCKDIVIDER
      if(count_melody[0] == 1)begin


	  case(melody)  //changing all 0001 to 1000, 1000 to 0001
	  0:seed <= 4'b0000;
      1:seed <= 4'b0100;
	  2:seed <= 4'b0010;
	  3:seed <= 4'b1000;
	  4:seed <= 4'b0001;//1000 //low2#
	  5:seed <= 4'b0100;
	  6:seed <= 4'b0010;
	  7:seed <= 4'b1000;
	  8:seed <= 4'b0001;//1000  //low5
	  9:seed <= 4'b0100;
	  10:seed <= 4'b0010;
	  11:seed <= 4'b1000;
	  12:seed <= 4'b0001;//1000 0010  //low7
	  13:seed <= 4'b0100;
	  14:seed <= 4'b0010;
	  15:seed <= 4'b1000;
	  16:seed <= 4'b0010;//1000 0010  //middle2#
	  17:seed <= 4'b0100;
	  18:seed <= 4'b0010;
	  19:seed <= 4'b1000;
	  20:seed <= 4'b0001;//1000 0010  //middle5
	  21:seed <= 4'b0100;
	  22:seed <= 4'b0010;
	  23:seed <= 4'b1000;
	  24:seed <= 4'b0010;//1000 0010  //middle7
	  25:seed <= 4'b0100;
	  26:seed <= 4'b0010;
	  27:seed <= 4'b1000;
	  28:seed <= 4'b0001;//1000 0010  //high2#
	  29:seed <= 4'b0100;
	  30:seed <= 4'b0010;
	  31:seed <= 4'b1000;
	  32:seed <= 4'b0010;//1000 0010  //high5
	  33:seed <= 4'b0100;
	  34:seed <= 4'b0010;
	  35:seed <= 4'b1000;
	  36:seed <= 4'b0001;//1000  //high7
	  37:seed <= 4'b0100;
	  38:seed <= 4'b0010;
	  39:seed <= 4'b1000;
	  40:seed <= 4'b0001;//1000
	  41:seed <= 4'b0100;
	  42:seed <= 4'b0010;
	  43:seed <= 4'b1000;
	  44:seed <= 4'b0001;//1000
	  45:seed <= 4'b0100;
	  46:seed <= 4'b0010;
	  47:seed <= 4'b1000;
	  48:seed <= 4'b0001;//1000
	  
	  
/*		case(melody)
	  0:seed <= 4'b0000;
     1:seed <= 4'b0100;
	  2:seed <= 4'b0010;
	  3:seed <= 4'b0001;
	  4:seed <= 4'b1000;//1000
	  5:seed <= 4'b0100;
	  6:seed <= 4'b0010;
	  7:seed <= 4'b0001;
	  8:seed <= 4'b1000;//1000
	  9:seed <= 4'b0100;
	  10:seed <= 4'b0010;
	  11:seed <= 4'b0001;
	  12:seed <= 4'b1000;//1000 0010
	  13:seed <= 4'b0100;
	  14:seed <= 4'b0010;
	  15:seed <= 4'b0001;
	  16:seed <= 4'b0010;//1000 0010
	  17:seed <= 4'b0100;
	  18:seed <= 4'b0010;
	  19:seed <= 4'b0001;
	  20:seed <= 4'b1000;//1000 0010
	  21:seed <= 4'b0100;
	  22:seed <= 4'b0010;
	  23:seed <= 4'b0001;
	  24:seed <= 4'b0010;//1000 0010
	  25:seed <= 4'b0100;
	  26:seed <= 4'b0010;
	  27:seed <= 4'b0001;
	  28:seed <= 4'b1000;//1000 0010
	  29:seed <= 4'b0100;
	  30:seed <= 4'b0010;
	  31:seed <= 4'b0001;
	  32:seed <= 4'b0010;//1000 0010
	  33:seed <= 4'b0100;
	  34:seed <= 4'b0010;
	  35:seed <= 4'b0001;
	  36:seed <= 4'b1000;//1000
	  37:seed <= 4'b0100;
	  38:seed <= 4'b0010;
	  39:seed <= 4'b0001;
	  40:seed <= 4'b1000;//1000
	  41:seed <= 4'b0100;
	  42:seed <= 4'b0010;
	  43:seed <= 4'b0001;
	  44:seed <= 4'b1000;//1000
	  45:seed <= 4'b0100;
	  46:seed <= 4'b0010;
	  47:seed <= 4'b0001;
	  48:seed <= 4'b1000;//1000*/
	  
	  default:seed <= 4'b0;
	  endcase
	end
	
	count_melody = count_melody + 24'b1; 
  	
	if (M==463) //if there's any change
   begin
			out <= seed;
	end

	end
endmodule